/*
 * @Author: zhao.dp
 * @Date: 2022-08-30 09:26:25
 * @LastEditors: zhao.dp
 * @LastEditTime: 2022-08-31 16:05:05
 * @Description:
 */
import path from 'path'
import { getFolder } from '../util/get-folder.mjs'

export default {
  description: '创建标准模块 Mock',
  prompts: [
    {
      type: 'list',
      name: 'path',
      message: '请选择模块目录',
      choices: getFolder('src/modules'),
    },
  ],
  actions: (data) => {
    let pathArr = path.relative('src/modules', data.path).split('\\')
    let moduleName = pathArr.pop()
    let relativePath = pathArr.join('/')
    const actions = []
    actions.push({
      type: 'add',
      path: 'dev-kit/mock/{{moduleName}}.ts',
      templateFile: 'dev-kit/plop-templates/mock/mock.hbs',
      data: {
        relativePath,
        moduleName,
      },
    })
    return actions
  },
}
